import React from 'react';
import { useEffect, useState } from 'react';
import { channelAPI } from 'api/channel';
import { Select } from 'antd';
const { Option } = Select;
export default function Channel(props) {
  const [channelList, setChannelList] = useState([]);

  const getChannelAPI = async () => {
    const res = await channelAPI();
    setChannelList(res.data.channels);
  };
  useEffect(() => {
    getChannelAPI();

    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
  // 获取列表
  return (
    <Select {...props} style={{ width: 200 }} placeholder="请选择频道列表">
      {channelList.map((item) => {
        return (
          <Option value={item.id} key={item.id}>
            {item.name}
          </Option>
        );
      })}
    </Select>
  );
}
